package com.wehealth;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

public class AboutUs extends Fragment {
	
	private MainActivity activity;


	public  AboutUs()
	{
		Log.i("init:", "AboutUs"); 
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

		return  inflater.inflate(R.layout.aboutus, null);
	}
	
	public void onActivityCreated(Bundle savedInstanceState){
		
		super.onActivityCreated(savedInstanceState);
		
		 activity = (MainActivity)getActivity();
		
		 Button bBack = (Button) activity.findViewById(R.id.bBack_AboutUs);
			
		 bBack.setOnClickListener(new View.OnClickListener()
			{
				public void onClick(View v)
				{
					
					Home vHome = new Home();
					
					if (getActivity() instanceof MainActivity)
					{
						MainActivity activity = (MainActivity) getActivity();
						
						activity.switchContent(vHome);
					}
					
					
				}
			});
		 
		 
		 TextView version_tv = (TextView)activity.findViewById(R.id.version_tv);
		 version_tv.setText(getVersion());
		 
	}
	
	 public String getVersion() {
		 try {
		          PackageManager manager = activity.getPackageManager();
		         PackageInfo info = manager.getPackageInfo(activity.getPackageName(), 0);
		          String version = info.versionName;
		         return activity.getString(R.string.version_name) + version;
		     } catch (Exception e) {
		         e.printStackTrace();
		         return activity.getString(R.string.can_not_find_version_name);
		     }
		 }

}
